package com.scy.java.object.finalTest;

import java.util.Arrays;

public class FinalReferenceTest {
    public static void main(String[] args) {
        //final修饰数组变量,iArr是引用变量
        final int[] iArr = {3,456,5,7,8};
        System.out.println(Arrays.toString(iArr));
        Arrays.sort(iArr);
        System.out.println("排序后："+Arrays.toString(iArr));
        //修改数组元素
        iArr[2] = -8;
        System.out.println("修改元素后"+Arrays.toString(iArr));
//        iArr =null;//此处代码语句对iArr重新赋值报编译错误

        final Person person = new Person();
        person.setAge(23);
        System.out.println(person.getAge());
        //尝试重新为person 赋值
//        person=null;//此处不允许
    }
}
class Person{
    private int age;
    //修饰常量的常量名称大写
    public static final String SEX="男";
    public Person(){

    }
    public Person(int age){
        this.age = age;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
